#include "textcolortab.h"

textColorTab::textColorTab()
{

}

void textColorTab::updateLabels(QString jsonData)
{
    //Convert the jsonData var to QJsonObject
    QJsonDocument jsonDataDocument = QJsonDocument::fromJson(jsonData.toUtf8());
    QJsonObject jsonDataDocumentObject = jsonDataDocument.object();

    //Convert the colors in the JSON to QColor
    QColor primaryColor, secondaryColor, iconSetColor, iconSetActiveColor, transitionScreen;
    primaryColor.setNamedColor("#" + jsonDataDocumentObject.value("primaryText").toString());
    secondaryColor.setNamedColor("#" + jsonDataDocumentObject.value("secondaryText").toString());
    iconSetColor.setNamedColor("#" + jsonDataDocumentObject.value("iconSet").toString());
    iconSetActiveColor.setNamedColor("#" + jsonDataDocumentObject.value("iconSetActive").toString());
    transitionScreen.setNamedColor("#" + jsonDataDocumentObject.value("transitionScreen").toString());

    //Update labels color
    emit setLabelsColor(primaryColor, secondaryColor, iconSetColor, iconSetActiveColor, transitionScreen);
}

QColor textColorTab::getColorFromUser()
{
    //Open the Color Selector dialog
    return QColorDialog::getColor();
}
